OCLOperators OnDelete

OnDelete is called when an object is deleted - much like a destructor.

The delete may fail due to the object - or one of the objects aggregates that is deleted as a consequence of Cascading delete - is not ready for delete (as if it has still associations not included in the cascading delete).

This may pose problems for you in certain scenarios like for example this example:

Documentation OCLOperators OnDelete 1734385240315.png

In the example above - when a Class1 object is deleted - almost all follow the Cascade delete rules due to the use of Composite on the association ends - however if the link from a class4-object has some class3-objects in its association that is "only" aggregate - the delete will halt - stating that the association end Class4-Class3s is not empty.

In this scenario you might find it beneficial to implement the OnDeleteReasonSolve(reason:string) method.

The OnDeleteReasonSolve method gives you the reason in the incoming parameter - but you may know what the problem is already and just implement the OnDeleteReasonSolve method with action language:

self.Class3s->clear 

The check will then be done again - and if no reasons not-to-delete remain the delete will go through.

OnDeleteReasonSolve is a special name recognized by the framework - much like OnDelete.

If no reason is found OnDeleteReasonSolve is not called.

If you do not solve the complete reason in OnDeleteReasonSolve the OnDeleteReasonSolve will be called again with the new top reason.

If you fail to solve the reason - the same exception is thrown stating the reason to the user.

See also: OnCreate, OnUpdate, OnStateChange

This page was edited 5 days ago on 12/16/2024. What links here